package fi.hell.lunchit

class ImageController {

    def restaurantLogo = {
		byte[] logoBytes = Restaurant.get(params.id)?.logo
		if (logoBytes) { 
			response.setContentLength(logoBytes.size())
			OutputStream out = response.getOutputStream()
			out.write(logoBytes)
			out.close()
		} else {
			response.sendError(404)
		    return;
		}
    }

    def companyLogo = {
		byte[] logoBytes = Company.get(params.id)?.logo
		if (logoBytes) {
			response.setContentLength(logoBytes.size())
			OutputStream out = response.getOutputStream()
			out.write(logoBytes)
			out.close()
		} else {
			response.sendError(404)
		    return;
		}
    }
}
